package web;

import service.brandService.brandService;
import service.brandServiceImpl.brandServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
@WebServlet("/deleteServlet")
public class deleteServlet extends HttpServlet {
    private brandService brandservice=new brandServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取id
        BufferedReader br = req.getReader();//获取axios请求体
        String s = br.readLine();
        int id= Integer.parseInt(s);//将string转化为int
        System.out.println(id);
        brandservice.deleteById(id);//执行删除的方法
        resp.getWriter().write("yes");//返回删除成功的信息
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
